/* Copyright 2007 Gearbox Software - http://www.gearboxsoft.com
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 
     http:www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.*/




namespace GearBlog.Web.ConfigSections
{
	using System.Configuration;

	/// <summary>
    /// Summary description for MembershipManagerSection
    /// </summary>
    public class MembershipManagerSection : ConfigurationSection
    {
        public class Fields
        {
            public const string RequiresApproval = "RequiresApproval";
            public const string Email = "Email";
            public const string Links = "Links";
            public const string AutoLogin = "AutoLogin";

        }
        public MembershipManagerSection()
        {

        }
        [ConfigurationProperty(Fields.RequiresApproval)]
        public bool RequiresApproval
        {
            get { return (bool)this[Fields.RequiresApproval]; }
            set { this[Fields.RequiresApproval] = value; }
        }

        [ConfigurationProperty(Fields.Email)]
        public EmailElement Email
        {
            get { return (EmailElement)this[Fields.Email]; }
            set { this[Fields.Email] = value; }
        }
        [ConfigurationProperty(Fields.Links, IsDefaultCollection=false)]
        [ConfigurationCollection(typeof(LinkElementCollection))]
        public LinkElementCollection Links
        {
            get { return (LinkElementCollection)this[Fields.Links]; }
            set { this[Fields.Links] = value; }
        }
        [ConfigurationProperty(Fields.AutoLogin)]
        public AutoLoginElement AutoLogin
        {
            get { return (AutoLoginElement)this[Fields.AutoLogin]; }
            set { this[Fields.AutoLogin] = value; }
        }
        public static MembershipManagerSection GetConfig()
        {
            return (MembershipManagerSection)ConfigurationManager.GetSection("MembershipManager");
        }
    }
    public class AutoLoginElement : ConfigurationElement
    {
        public class Fields
        {
            public const string Enabled = "Enabled";
            public const string UserName = "UserName";
            public const string Password = "Password";
        }
        [ConfigurationProperty(Fields.Enabled)]
        public bool Enabled
        {
            get { return (bool)this[Fields.Enabled]; }
            set { this[Fields.Enabled] = value; }
        }
        [ConfigurationProperty(Fields.UserName)]
        public string UserName
        {
            get { return (string)this[Fields.UserName]; }
            set { this[Fields.UserName] = value; }
        }
        [ConfigurationProperty(Fields.Password)]
        public string Password
        {
            get { return (string)this[Fields.Password]; }
            set { this[Fields.Password] = value; }
        }
    }
    public class LinkElementCollection : ConfigurationElementCollection
    {
        protected override ConfigurationElement CreateNewElement()
        {
            return new LinkElement();
        }
        protected override ConfigurationElement CreateNewElement(string elementName)
        {
            return new LinkElement(elementName);
        }
        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((LinkElement)element).Key;
        }
        public new LinkElement this[string key]
        {
            get { return (LinkElement) base.BaseGet(key); }
        }
        
    }
    public class LinkElement : ConfigurationElement
    {
        public class Fields
        {
            public const string Key = "Key";
            public const string Area = "Area";
            public const string Controller = "Controller";
            public const string Action = "Action";
            //public const string QueryString = "QueryString";
        }
        public LinkElement(string key)
        {
            Key = key;
        }
        public LinkElement()
        {
        }

        [ConfigurationProperty(Fields.Key)]
        public string Key
        {
            get { return (string)this[Fields.Key]; }
            set { this[Fields.Key] = value; }
        }
        [ConfigurationProperty(Fields.Area)]
        public string Area
        {
            get { return (string)this[Fields.Area]; }
            set { this[Fields.Area] = value; }
        }

        [ConfigurationProperty(Fields.Controller)]
        public string Controller
        {
            get { return (string)this[Fields.Controller]; }
            set { this[Fields.Controller] = value; }
        }

        [ConfigurationProperty(Fields.Action)]
        public string Action
        {
            get { return (string)this[Fields.Action]; }
            set { this[Fields.Action] = value; }
        }
        /*

        [ConfigurationProperty(Fields.QueryString)]
        public string QueryString
        {
            get { return (string)this[Fields.QueryString]; }
            set { this[Fields.QueryString] = value; }
        }
         */

    }
    /*
    public class LinksElement : ConfigurationElement
    {
        public class Fields
        {
            public const string LoginUrl = "LoginUrl";
            public const string AccessDeniedUrl = "AccessDeniedUrl";
            public const string MainMenuUrl = "MainMenuUrl";
        }

        [ConfigurationProperty(Fields.LoginUrl)]
        public string LoginUrl
        {
            get { return (string)this[Fields.LoginUrl]; }
            set { this[Fields.LoginUrl] = value; }
        }
        [ConfigurationProperty(Fields.AccessDeniedUrl)]
        public string AccessDeniedUrl
        {
            get { return (string)this[Fields.AccessDeniedUrl]; }
            set { this[Fields.AccessDeniedUrl] = value; }
        }
        [ConfigurationProperty(Fields.MainMenuUrl)]
        public string MainMenuUrl
        {
            get { return (string)this[Fields.MainMenuUrl]; }
            set { this[Fields.MainMenuUrl] = value; }
        }
    }
     */
    public class EmailElement : ConfigurationElement
    {
        public class Fields
        {
            public const string From = "From";
            public const string Signature = "Signature";
            public const string System = "System";
            public const string ReplyEmail = "ReplyEmail";
        }

        public EmailElement()
        {

        }

        [ConfigurationProperty(Fields.From)]
        public string From
        {
            get { return (string)this[Fields.From]; }
            set { this[Fields.From] = value; }
        }

        [ConfigurationProperty(Fields.Signature)]
        public string Signature
        {
            get { return (string)this[Fields.Signature]; }
            set { this[Fields.Signature] = value; }
        }
        [ConfigurationProperty(Fields.System)]
        public string System
        {
            get { return (string)this[Fields.System]; }
            set { this[Fields.System] = value; }
        }

        [ConfigurationProperty(Fields.ReplyEmail)]
        public string ReplyEmail
        {
            get { return (string)this[Fields.ReplyEmail]; }
            set { this[Fields.ReplyEmail] = value; }
        }
    }
}